public class AudioDemo extends java.applet.Applet {
    java.applet.AudioClip clip;
    java.applet.AppletContext context;

    @Override
    public void init() {
        super.init();
        context = getAppletContext();
        String audioURL = this.getParameter("audio");
        if (audioURL == null) {
            audioURL = "default.au";
        }
        try {
            java.net.URL url = new java.net.URL(this.getDocumentBase(), audioURL);
            clip = context.getAudioClip(url);
        } catch (java.net.MalformedURLException e) {
            e.printStackTrace();
            context.showStatus("Could not load audio file!");
        }
    }


    @Override
    public void start() {
        super.start();
        if (clip != null) {
            clip.loop();
        }
    }

    @Override
    public void stop() {
        super.stop();
        if (clip != null) {
            clip.stop();
        }
    }
}
